<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录弹窗</title>
<script type="text/javascript" src="http://www.39249.com/libs/jquery.min.js"></script> 
	<link type="text/css" media="screen" rel="stylesheet" href="http://www.39249.com/resources/css/global.css">
	<link rel="stylesheet" href="http://www.39249.com/resources/css/detail.css" media="all"/>
	<link rel="stylesheet" href="http://www.39249.com/resources/css/content.css" media="all"/>
	<link rel="stylesheet" href="http://www.39249.com/resources/css/common.css" media="all"/>
	<link rel="shortcut icon" href="http://www.39249.com/resources/images/favicon.ico" media="all"/>
	<script src="http://www.39249.com/libs/artDialog/artDialog.js"></script>
	<script src="http://www.39249.com/libs/artDialog/plugins/iframeTools.js"></script>

<link type="text/css" rel="stylesheet" href="http://style.esunnyimg.com/style/css/base.css?v=20120628200700019" />
<link type="text/css" rel="stylesheet" href="http://style.esunnyimg.com/style/css/login.css?v=20120628200700019" />
<script type="text/javascript">
//调用父页面函数：window.parent.fnName()
</script>
</head>
<body>
<div class="iframe-loginbox">
	<div class="ilogin-inner">

    	<ul class="ilogin-tab">
        	<li class="cur" rel="iloginBox" onclick="switchboxFn('iloginBox','iregistBox')">登录</li>
            <li rel="iregistBox" onclick="switchboxFn('iregistBox','iloginBox')">注册</li>
        </ul>
        
        <form id="loginForm">
        <div class="iloginbox" id="iloginBox">
        	<div class="error-box" id="error1" style="display:none;margin: 0 10px 10px 20px;"></div>
					<div class="ui-form-item" style="margin-bottom: 5px;">
						<label for="ipt-search-key" class="ui-form-label required">手机号码：</label>
						<input id="mobile1" class="ui-input required" maxLength="80" value="" tabindex="1"/>
						<div class="fm-explain" id="mobile1-tip"></div>
					</div>
					<div class="ui-form-item" style="margin-bottom: 5px;">
						<label for="ipt-search-key" class="ui-form-label required">登录密码：</label>
						<input id="password1" type="password" class="ui-input required" maxLength="80" value="" tabindex="2"/>
						<div class="fm-explain" id="psd1-tip"></div>
					</div>
					<div class="ui-form-item" style="margin-bottom: 5px;">
						<label for="ipt-search-key" class="ui-form-label required">验证码：</label>
						<input id="checkCode1" class="ui-input required" maxLength="80" value="" tabindex="3" style="width:50px"/>
						<img title="看不清，点击换一换" src="http://www.39249.com/checkCode.htm" width="80" height="30" id="checkCodeImage"  style="margin-bottom: -10px"/>
						<a href="#" id="checkCodeHref">看不清,换一张</a>
						<div class="fm-explain" id="checkcode1-tip"></div>
					</div>
					<div class="ui-form-item">
				       <span class="btn btn-ok">
				            <input type="button" value="登录" onclick="login()"  style="margin-right:0px"/>
				       </span>
					</div>
					
					<div class="ilogin-info">我们需要一个账号保存您的付款信息，以便您后续查询。没有账号？请<a href="#" class="blue" onclick="switchboxFn('iregistBox','iloginBox');return false;">注册</a></div>
		</div>
		</form>
	
		<form id="joinForm">
			<div class="iregistbox"  style="display:none" id="iregistBox">
			<div class="error-box" style="display:none;margin: 0 10px 10px 20px;" id="error2"></div>
			<div class="ui-form-item" style="margin-bottom: 2px;">
						<label for="ipt-search-key" class="ui-form-label required">手机号码</label>
						<input id="mobile" class="ui-input required" maxLength="80" value="" tabindex="1"/>
						<div class="fm-explain" id="mobile-tip"></div>
			</div>
			<div class="ui-form-item" style="margin-bottom: 2px;">
				<label for="ipt-search-key" class="ui-form-label required">
					登录密码
				</label>
				<input id="password" type="password" class="ui-input required" maxLength="80" tabindex="2"/>
				<div class="fm-explain" id="psd-tip" ><font color="#B2B2B2">长度为6~20位,由数字、字母或下划线组成</font></div>
			</div>
			<div class="ui-form-item" style="margin-bottom: 2px;">
				<label for="ipt-search-key" class="ui-form-label required">
					确认密码
				</label>
				<input id="repassword" type="password" class="ui-input" maxLength="80" tabindex="3"/>
				<div class="fm-explain" id="psd2-tip"></div>
			</div>
			<!--
			<div class="ui-form-item" style="margin-bottom: 2px;">
				<label for="ipt-search-key" class="ui-form-label required">
					真实姓名
				</label>
				<input id="nick" class="ui-input required" maxLength="80" tabindex="4"/>
				<div class="fm-explain" id="nick-tip"><font color="#B2B2B2">请务必填写真实姓名，否则将无法结算</font></div>
			</div>
			<div class="ui-form-item" style="margin-bottom: 2px;">
				 
				<label for="ipt-search-key" class="ui-form-label required">
					验证码
				</label>
				<input id="checkcode" class="ui-input required" maxLength="40" tabindex="5" style="width:80px"/>
				
				<img title="看不清，点击换一换" src="http://www.39249.com/checkCode.htm" width="100" height="30" id="checkCodeImage"  style="margin-bottom: -10px"/>
				<a href="#" id="checkCodeHref">看不清,换一张</a>
				 
				<div class="fm-explain" id="checkcode-tip"></div>
			
			</div>
				-->
			<input style="padding-left:90px" id="checkService" name="" type="checkbox" value="" checked /><span style="font-family:'宋体'">我已看过并同意<a target="_blank" href="http://www.39249.com/prot.html" class="blue">《聚宝盆服务协议》</a></span> 
			<div class="fm-item">
		       <span class="btn btn-ok">
		            <input type="button" value="注册" onclick="register()" style="margin-right:0px"/>
		       </span>
			</div>

            <div class="ilogin-info">我们需要一个账号保存您的交易信息，以便您后续查询。已有账号？请<a href="#" class="blue" onclick="switchboxFn('iloginBox','iregistBox');return false;">登录</a></div>
        </div> 
		</form>
    </div>
</div>

<script type="text/javascript"  src="http://style.esunnyimg.com/style/js/member/pop_join.js?v=20120628200700019"></script>
<script>

	$(function(){    
		var $div_li =$("div.tab_menu ul li");
		
		$("div.tab_menu ul li").click(function(){
			$(this).addClass("selected").siblings().removeClass("selected");
			var index =  $div_li.index(this);          
			$("div.tab_box > div").eq(index).show().siblings().hide();
		}).hover(function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		});
		
	});

	function login() {
		$("#loginForm .required:input").trigger('blur');
		var numError = $('#loginForm .onError').length;
		if(numError){
			return false;
		}
		
		var mobile = $("#mobile1").val();
		var password = $("#password1").val();
		var checkCode = $("#checkCode1").val();
		
		$.post('http://www.39249.com/login.htm', {
			'mobile' : mobile,
			'password' : password,
			'checkCode':checkCode
		}, function(data) {
			var str = $.trim(data);
			if (str == "success") {
				$(window.parent.document).find("#loginpop").css("display","none");
				$.post('http://www.39249.com/getloginfo.htm',{
				},function(info){
					var json = (new Function("return " + info))(); 
					$(window.parent.document).find("#payerId").val(json.id);
					$(window.parent.document).find("#global-toplink-username").empty();
					$(window.parent.document).find("#loginhref").css("display","none");
					$(window.parent.document).find("#global-toplink-username").append("欢迎你,"+json.nick);
				});
				
				parent.payconfirm();
				return true;
			} else {
				$("#error1").empty();
				$("#error1").css("display", "block").append(data);
			}
		});
	}

				
		$('#loginForm :input').blur(function(){
			var $parent = $(this).parent();
			$parent.find(".formtips").remove();
			
			if($(this).is('#mobile1')){
				var pattern = /^(13[0-9]|147|15[0|1|2|3|5|6|7|8|9]|18[0|2|3|5|6|7|8|9])\d{8}$/;
				if(this.value == "" || this.value == null || !pattern.test(this.value)){
					$('#mobile1-tip').empty();
					$('#mobile1-tip').append("<span class='formtips onError' style='color:red'>请填写手机号码</span>");
				}
			}
			if($(this).is('#checkCode1')){
				if(this.value == "" || this.value == null){
					$('#checkcode1-tip').empty();
					$('#checkcode1-tip').append("<span class='formtips onError' style='color:red'>请填写验证码</span>");
				}
			}
			
			$(document).bind('keydown', function (e) {
	            var key = e.which;
	            if (key == 13) {
	                e.preventDefault();
	                login();
	            }
	        });
		});
		
		
		
		$('#joinForm :input').blur(function(){
			var $parent = $(this).parent();
			$parent.find(".formtips").remove();
			
			
			if($(this).is('#mobile')){
				var pattern = /^(13[0-9]|147|15[0|1|2|3|5|6|7|8|9]|18[0|2|3|5|6|7|8|9])\d{8}$/;
				if(this.value == "" || this.value == null || !pattern.test(this.value)){
					$('#mobile-tip').empty();
					$('#mobile-tip').append("<span class='formtips onError' style='color:red'>请填写手机号码</span>");
					//$parent.append("<span class='formtips onError' style='color:red'>请填写手机号码</span>");
				}
				
				$ .post('http://www.39249.com/registerCheck.htm',{
					'mobile':this.value
				},function(data){
					$("#mobile-tip").empty();
					if(data == "success"){
						$("#mobile-tip").append("<span class='formtips onPass' style='color:green'>该手机号码可以使用</span>");
					}else{
						$("#mobile-tip").append("<span class='formtips onError'>"+data+"</span>");
					}
				});
			}
			
			if($(this).is('#password')){
				var pattern = /^\w{6,20}$/;
				if(this.value == "" || this.value == null || !pattern.test(this.value)){
					$("#psd-tip").empty();
					$("#psd-tip").append("<span class='formtips onError' style='color:red'>长度为6-20位,由数字、字母或下划线组成</span>");
				}
			}
			
			if($(this).is('#repassword')){
				if(this.value == "" || this.value != $("#password").val()){
					$("#psd2-tip").empty();
					$("#psd2-tip").append("<span class='formtips onError' style='color:red'>两次输入的密码不一致</span>");
				}
			}
			
			if($(this).is('#nick')){
				var pattern = /^[\u4e00-\u9fa5]{2,6}$/; 
				if(this.value == "" || this.value == null || !pattern.test(this.value)){
					$("#nick-tip").empty();
					$("#nick-tip").append("<span class='formtips onError' style='color:red'>请填写中文名</span>");
				}
			}
			
			if($(this).is('#checkcode')){
				if(this.value == "" || this.value == null){
					$("#checkcode-tip").empty();
					$("#checkcode-tip").append("<span class='formtips onError' style='color:red'>请输入验证码</span>");
				}
			}
		});
		
		function register(){
			$("#joinForm .required:input").trigger('blur');
			var numError = $('form .onError').length;
			if(numError){
				return false;
			}
			
			var mobile = $("#mobile").val();
			var password = $("#password").val();
			var repassword = $("#repassword").val();
			var nick= $("#nick").val();
			var checkcode = $("#checkcode").val();
			
			$ .post('http://www.39249.com/register.htm',{
				'mobile':mobile,
				'password':password,
				'nick':nick,
				'checkCode':checkcode
	    	},function(data){
	    		var str = $.trim(data);
	    		if (str == "success") {
					$(window.parent.document).find("#loginpop").css("display","none");
					$.post('http://www.39249.com/getloginfo.htm',{
					},function(info){
						var json = (new Function("return " + info))(); 
						$(window.parent.document).find("#payerId").val(json.id);
						$(window.parent.document).find("#global-toplink-username").empty();
						$(window.parent.document).find("#loginhref").css("display","none");
						$(window.parent.document).find("#global-toplink-username").append("欢迎你,"+json.nick);
					});
					
					parent.payconfirm();
					return true;
				}else{
	    			if(data == "codeError"){
	    				$("#checkcode-tip").empty();
	    				$("#checkcode-tip").append("<span class='formtips onError' style='color:red'>验证码错误</span>");
	    			}else if(data == "mobileError"){
	    				$("#mobile-tip").empty();
	    				$("#mobile-tip").append("<span class='formtips onPass' style='color:green'>该手机号码已被注册</span>");
	    			}else{
	    				$("error2").empty();
	    				$("error2").css("display", "block").append(data);
	    			}
	    		}
	    	});
		}
		
		$(function(){           
	    	$('#checkCodeImage').click(function () {//生成验证码  
	     	$(this).hide().attr('src', 'http://www.39249.com/checkCode.htm?' + Math.floor(Math.random()*100) ).fadeIn(); })      
	    });  
		
		$('#checkCodeHref').bind('click',function () {//生成验证码  
	     	$('#checkCodeImage').hide().attr('src', 'http://www.39249.com/checkCode.htm?' + Math.floor(Math.random()*100) ).fadeIn(); 
		});      
</script>
</body>
</html>